<style type="text/css">
    .demo-upload-list {
        display: inline-block;
        width: 60px;
        height: 60px;
        text-align: center;
        line-height: 60px;
        border: 1px solid transparent;
        border-radius: 4px;
        overflow: hidden;
        background: #fff;
        position: relative;
        box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
        margin-right: 4px;
    }

    .demo-upload-list img {
        width: 100%;
        height: 100%;
    }

    .demo-upload-list-cover {
        display: none;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, .6);
    }

    .demo-upload-list:hover .demo-upload-list-cover {
        display: block;
    }

    .demo-upload-list-cover i {
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        margin: 0 2px;
    }

    .selected-search {
        box-shadow: 0 1px 6px rgba(0, 0, 0, .2);
        height: 200px;
        width: 260px;
        position: relative;
        border-radius: 4px;
    }

    .selected-search .search-action {
        position: absolute;
        top: 10px;
        left: 10px;
        right: 10px;
    }

    .selected-search .selected-arr {
        position: absolute;
        top: 50px;
        left: 20px;
        right: 20px;
        bottom: 10px;
        overflow: scroll;
    }

    .select-click {
        border: 1px solid #dddee1;
        border-radius: 4px;
        padding: 0 10px;
        margin-bottom: 10px;
    }

    .selected-search .selected-arr .selected-item {
        /*border-bottom: 1px solid #dfdfdf;*/
    }
</style>
<template>
    <i-form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80">
        <selectSearch :selectBaseInfo="selectBaseInfo" @post-data="getCompentensData"></selectSearch>
        <Form-item>
            <i-button @click="handleSubmit('formValidate')" type="primary">提交</i-button>
            <i-button   style="margin-left: 8px">取消</i-button>
        </Form-item>
    </i-form>
</template>
<script>
    import apiUtil from '../../assets/utils/api_util';
    import selectSearch from '../../components/selectSearch';


    export default {
        data() {
            return {
                formValidate: {},
                ruleValidate: {},
                //选择部门
                selectBaseInfo: {
                    "title": '选择组织',
                    "placeholder": '请输入所在组织名称',
                    "postUrl": apiUtil.urls.OrganSearch,
                },
                reqpeopleDept: '',
            }
        },
        mounted: function () {
        },

        components: {
            selectSearch
        },
        methods: {
            handleSubmit(name) {

                let that = this;
                // let model = this.$refs[name].model;
                // console.log('this.$refs[name].model:', this.$refs[name].model);
                // console.log(this.$refs[name].validate());
                //
                // this.$refs[name].validate((valid) => {
                //     that.addData(model);
                //     console.log('dddddfdsfsdfsdf')
                //
                // })
                this.addData(that.formValidate)
            },

            //获取选择搜索组件传来结果数据
            getCompentensData: function (value) {
                this.reqpeopleDept = value;
            },

            //添加
            addData: function (model) {
                let that = this;

                model.peopleId = this.$route.query.id;
                model.orgId = this.reqpeopleDept.resultId;

                let params = that.$qs.stringify(model);
                this.$Loading.start();

                apiUtil.post(that, apiUtil.urls.AddPeopleOrgInfo, params, function (res) {
                    that.$Loading.finish();

                    that.$Notice.warning({
                        top: 50,
                        duration: 3,
                        title:'添加成功 '
                    })

                });
            },

            uploadList() {
                let that = this;
                this.imageList = that.$refs.upload ? that.$refs.upload.fileList : [];
                console.log('this.imageList:', this.imageList);
            },

        }
    }
</script>
